<?php 

/**
 * [CT 时间转换]
 * @Author   Xuebingsi
 * @DateTime 2017-03-08T08:56:40+0800
 * @param    [int]                   $time [时间戳]
 */
function CT($time)
{
    $diff = time()-$time;
    if($diff<60){
        return "刚刚";
    }elseif($diff<3600){
        return round($diff/60)."分钟之前";
    }elseif($diff<86400){
        return round($diff/60/60)."小时之前";
    }elseif($diff<(86400*7)){
        return round($diff/86400)."天之前";
    }else{
        return date('Y-m-d H:i:s',$time);
    }
}

function xbsemail($email,$title,$content)
{
    
    // require './PHPMailerAutoload.php';

    Vendor('PHPMailer.PHPMailerAutoload');


    $mail = new PHPMailer;

    // var_dump($mail);exit;

    //$mail->SMTPDebug = 3;                               // Enable verbose debug output

    $mail->isSMTP();                                      // Set mailer to use SMTP
    $mail->Host = 'smtp.qq.com';  // Specify main and backup SMTP servers
    $mail->SMTPAuth = true;                               // Enable SMTP authentication
    $mail->Username = '113664000@qq.com';                 // SMTP username
    $mail->Password = 'cupajuooynascahf';                           // SMTP password
    $mail->SMTPSecure = 'ssl';                            // Enable TLS encryption, `ssl` also accepted
    $mail->Port = 465;                                    // TCP port to connect to

    $mail->setFrom('113664000@qq.com', '学并思');
    $mail->addAddress($email, '接收人');     // Add a recipient
    // $mail->addAddress('ellen@example.com');               // Name is optional
    // $mail->addReplyTo('info@example.com', 'Information');
    // $mail->addCC('cc@example.com');
    // $mail->addBCC('bcc@example.com');

    // $mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments
    // $mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name
    $mail->isHTML(true);                                  // Set email format to HTML

    $mail->Subject = $title;
    $mail->Body    = $content;

    if(!$mail->send()) {
        echo 'Message could not be sent.';
        echo 'Mailer Error: ' . $mail->ErrorInfo;
    } else {
        echo 'Message has been sent';
    }

}

function xbslogin()
{
    Vendor('QQConnect.API.qqConnectAPI');

    $qc = new \QC();

    $qc->qq_login();
}

function getOpenid()
{
    Vendor('QQConnect.API.qqConnectAPI');

    $qc = new \QC();

    $qc->qq_callback();

    return $qc->get_openid();
}

function getUserInfo()
{

    Vendor('QQConnect.API.qqConnectAPI');

    $qc = new \QC();

    return $qc->get_user_info();
}
















 ?>